package com.jlnk.stockdemo.bean;

import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;

public class ForexListResponse {

    @SerializedName("request_id")
    private String requestId;

    @SerializedName("code")
    private int code;

    @SerializedName("data")
    private ForexListResponse.Data data;

    @SerializedName("msg")
    private String msg;

    public String getRequestId() {
        return requestId;
    }

    public int getCode() {
        return code;
    }

    public ForexListResponse.Data getData() {
        return data;
    }

    public String getMsg() {
        return msg;
    }

    public static class Data {
        @SerializedName("fields")
        private List<String> fields;

        @SerializedName("items")
        private List<List<String>> items;

        @SerializedName("has_more")
        private boolean hasMore;

        @SerializedName("count")
        private int count;

        private List<Forex> forexList;

        public List<String> getFields() {
            return fields;
        }

        public List<List<String>> getItems() {
            return items;
        }

        public boolean isHasMore() {
            return hasMore;
        }

        public int getCount() {
            return count;
        }

        public List<Forex> getForexList() {
            forexList = new ArrayList<>();
            int tsCodeIndex, nameIndex, classifyIndex, exchangeIndex, pip_costIndex, traget_spreadIndex;
            tsCodeIndex = nameIndex = classifyIndex = exchangeIndex = pip_costIndex = traget_spreadIndex = 0;
            for (int i = 0; i < fields.size(); i++) {
                switch (fields.get(i)) {
                    case "ts_code" :
                        tsCodeIndex = i;
                        break;
                    case "name" :
                        nameIndex = i;
                        break;
                    case "classify" :
                        classifyIndex = i;
                        break;
                    case "exchange" :
                        exchangeIndex = i;
                        break;
                    case "pip_cost" :
                        pip_costIndex = i;
                        break;
                    case "traget_spread" :
                        traget_spreadIndex = i;
                        break;
                }
            }
            for (int j = 0; j < items.size(); j++) {
                Forex forex = new Forex();
                forex.setTsCode(items.get(j).get(tsCodeIndex));
                forex.setName(items.get(j).get(nameIndex));
                forex.setClassify(items.get(j).get(classifyIndex));
                forex.setExchange(items.get(j).get(exchangeIndex));
                forex.setPip_cost(items.get(j).get(pip_costIndex));
                forex.setTraget_spread(items.get(j).get(traget_spreadIndex));
                forexList.add(forex);
            }
            return forexList;
        }

        public static class Forex {
            private String tsCode;
            private String name;
            private String classify;
            private String exchange;
            private String pip_cost;
            private String traget_spread;

            public String getTsCode() {
                return tsCode;
            }

            public void setTsCode(String tsCode) {
                this.tsCode = tsCode;
            }

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }

            public String getClassify() {
                return classify;
            }

            public void setClassify(String classify) {
                this.classify = classify;
            }

            public String getExchange() {
                return exchange;
            }

            public void setExchange(String exchange) {
                this.exchange = exchange;
            }

            public String getPip_cost() {
                return pip_cost;
            }

            public void setPip_cost(String pip_cost) {
                this.pip_cost = pip_cost;
            }

            public String getTraget_spread() {
                return traget_spread;
            }

            public void setTraget_spread(String traget_spread) {
                this.traget_spread = traget_spread;
            }
        }
    }
}
